updating oE powof2

powof2

include math.e 
namespace math 
public function powof2(object p) 

tests for power of 2.

Parameters:
  1. p : an object. The item to test. This can be an integer, atom or sequence.
Returns:

An integer,

  • 1 for each item in p that is a power of two (like 2,4,8,16,32, ...)
  • 0 for each item in p that is not a power of two (like 3, 54.322, -2)
Example 1:
for i = 1 to 10 do 
  ? {i, powof2(i)} 
end for 
-- output ...  
-- {1,1} 
-- {2,1} 
-- {3,0} 
-- {4,1} 
-- {5,0} 
-- {6,0} 
-- {7,0} 
-- {8,1} 
-- {9,0} 
-- {10,0} 
Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu